﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter21.ViewModel
{
    using System.Windows;
    using System.Windows.Controls;

    public class ProductByCategoryStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            var product = (Product)item;
            var window = Application.Current.MainWindow;
            if (product.CategoryName == "Travel")
            {
                return (Style)window.FindResource("TravelProductStyle");
            }
            else
            {
                return (Style)window.FindResource("DefaultProductStyle");
            }
        }
    }
}
